package cn.suxiaoxiang.suwebverify.events;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;

import static cn.suxiaoxiang.suwebverify.events.PlayerJoin.PLAYER_SESSIONS;
import static org.bukkit.Bukkit.getLogger;

/**
 * PlayerLogoutListener - 玩家退出事件
 *
 * @author 程序员-Su_xiaoxiang
 * @date 2025/4/7 20:55
 */

public class PlayerLogoutListener implements Listener {

    // 玩家退出时清除其登录状态
    @EventHandler
    public void onPlayerQuit(PlayerQuitEvent event) {
        String playerName = event.getPlayer().getName();

        // 从 PLAYER_SESSIONS 中移除该玩家的登录状态
        if (PLAYER_SESSIONS.containsKey(playerName)) {
            PLAYER_SESSIONS.remove(playerName);
            //输出启动信息
            getLogger().info("SuWebVerify 退出！");
        }
    }
}
